//
//  Edit_addTextView.m
//  SoundPill
//
//  Created by 宋旭东 on 15/3/4.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "Edit_addTextView.h"

@implementation Edit_addTextView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews];
    }
    return self;
}
- (void)createSubviews
{
    self.textView = [[UITextView alloc] initWithFrame:CGRectMake(10, 0, (self.frame.size.width - 20) / 3 * 2, self.frame.size.height)];
    _textView.textColor = [UIColor whiteColor];
    _textView.textAlignment = NSTextAlignmentLeft;
    _textView.font = [UIFont systemFontOfSize:18];
    _textView.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.440];
    [self addSubview:_textView];
    
    self.textLength =  [[UILabel alloc] initWithFrame:CGRectMake((self.frame.size.width - 20) / 3 * 2 - 50, self.frame.size.height - 12, 40, 10)];
    _textLength.font = [UIFont systemFontOfSize:12];
    _textLength.backgroundColor = [UIColor clearColor];
    _textLength.text = @"0/40";
    _textLength.textAlignment = NSTextAlignmentRight;
    _textLength.textColor = [UIColor colorWithWhite:0.852 alpha:0.60];
    [self addSubview:_textLength];
    
    self.cancel = [UIButton buttonWithType:UIButtonTypeCustom];
    _cancel.frame = CGRectMake((self.frame.size.width - 20) / 3 * 2 + 20, self.frame.size.height - 40, 40, 40);
    [_cancel setImage:[UIImage imageNamed:@"quxiaowenzi"] forState:UIControlStateNormal];
    [self addSubview:_cancel];
    
    self.done = [UIButton buttonWithType:UIButtonTypeCustom];
    _done.frame = CGRectMake(_cancel.frame.origin.x + _cancel.frame.size.width + 10, _cancel.frame.origin.y, 40, 40);
    [_done setImage:[UIImage imageNamed:@"quedingwenzi"] forState:UIControlStateNormal];
    [self addSubview:_done];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.textView.frame = CGRectMake(10, 0, (self.frame.size.width - 20) / 3 * 2, self.frame.size.height);
    self.cancel.frame = CGRectMake((self.frame.size.width - 20) / 3 * 2 + 20, self.frame.size.height - 40, 40, 40);
    self.done.frame = CGRectMake(_cancel.frame.origin.x + _cancel.frame.size.width + 10, _cancel.frame.origin.y, 40, 40);
    self.textLength.frame = CGRectMake((self.frame.size.width - 20) / 3 * 2 - 35, self.frame.size.height - 12, 40, 10);
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
